package zjh_20230405;

import java.time.LocalTime;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class ScheduledThreadPool {
    public static void main(String[] args) {
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2);
        for (int i = 0; i < 3; i++) {
            int number = i;
            scheduledExecutorService.schedule(new Runnable() {
                @Override
                public void run() {
                    System.out.println("当前时间:" + LocalTime.now() + ", 线程: " +
                            Thread.currentThread().getName() + ", 序号：" + number);
                }
            },2, TimeUnit.SECONDS);
        }
//        System.out.println(scheduledExecutorService.isShutdown());

        scheduledExecutorService.shutdown();
        System.out.println(scheduledExecutorService.isShutdown());

//        scheduledExecutorService.shutdownNow();
    }
}
